package StudyCode.summary.zipfile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.zip.GZIPInputStream;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class IsGzipFileByItsContent {
	public static void main(String[] argv) throws Exception {
		File f = new File("E:/Copy/zipdemo.zip");
		System.out.println("通过文件内容判断是不是 Gzip 文件 ? " + isGzip(f));
	}

	public static boolean isGzip(final File f) throws IOException {
		FileInputStream fis;
		boolean returnValue = false;

		fis = new FileInputStream(f);
		try {
			new GZIPInputStream(fis);
			returnValue = true;
		} catch (final IOException io) {


		} finally {
			if (fis != null) {
				fis.close();
			}
		}

		return returnValue;
	}
}
